<script setup lang="ts">
import QuestionToolbar from '../components/QuestionToolbar.vue'
import GlobalHeader from '../components/GlobalHeader.vue'
import { ref, onMounted, onUnmounted } from 'vue'

const isMobile = ref(false)

const checkMobile = () => {
  isMobile.value = window.innerWidth <= 768
}

onMounted(() => {
  checkMobile()
  window.addEventListener('resize', checkMobile)
})

onUnmounted(() => {
  window.removeEventListener('resize', checkMobile)
})
</script>

<template>
  <div id="questionLayout">
    <el-container>
      <el-header height="56px">
        <QuestionToolbar v-if="!isMobile" />
        <GlobalHeader v-else />
      </el-header>
      <el-main class="content">
        <router-view/>
      </el-main>
    </el-container>
  </div>
</template>

<style scoped>
#questionLayout {
  background-color: #F0F0F0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.el-container {
  height: 100%;
}

.el-header {
  padding: 0;
  background-color: white;
}

.content {
  flex: 1;
  overflow: auto;
  padding: 0;
}

.footer {
  height: 40px;
  line-height: 40px;
  background-color: white;
  border-top: 1px solid #e4e7ed;
}

@media screen and (max-width: 768px) {
  .el-header {
    height: 60px !important;
  }
  
  .content {
    padding: 0;
  }
}
</style>
